/*************************************************************************
	> File Name: oj-272.cpp
	> Author: Wang Bo
	> Mail: 1276106221@qq.com
	> Created Time: 2021年02月02日 星期二 17时38分09秒
 ************************************************************************/
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <utility>

#define MAX_N 100000
using namespace std;
using ll = long long;

struct Node {
    ll val;
    int id;
};

Node arr[MAX_N + 5], ans[MAX_N + 5];

int f[MAX_N + 5], left[MAX_N + 5], right[MAX_N + 5];

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%lld", &arr[i].val);
        arr[i].id = i;
    }
    sort(arr + 1, arr + n + 1, [](const Node& a, const Node& b){
        return a.val < b.val;
    });
    arr[n + 1].val = 0x3f3f3f3f, arr[0].val = -arr[n + 1].val;
    for (int i = 1; i <= n; ++i) {
        f[arr[i].id] = i; //id和序号映射关系
        left[i] = i - 1;
        right[i] = i + 1;
    }
    for (int i = n; i >= 1; --i) {
        //int j = f[i], l = j - 1, r = j + 1;
        int j = f[i], l = left[j], r = right[j];
        printf("l = %d, r = %d\n", l, r);
        ll val_l = abs(arr[l].val - arr[j].val);
        ll val_r = abs(arr[r].val - arr[j].val);
        if (val_l <= val_r) ans[i] = (Node){val_l, arr[l].id};
        else ans[i] = {val_r, arr[r].id};
        left[r] = l;
        right[l] = r;
    }
    for (int i = 2; i <= n; ++i) {
        printf("%lld %d\n", ans[i].val, ans[i].id);
    }
    return 0;
}
